#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
  pid_t pid = fork();
  if(pid == 0)
  {
    int t = 5;
    while(t--)
    {
      printf("I am a child process\n");
      sleep(1);
    }
    int c = 5 / 0;//进行除0非法操作，验证异常退出
    exit(100);
  }
  printf("I am a father process and I am waiting\n");
  int status = 0;
  wait(&status);
   printf("waiting success,exit_signal:%d\n",WIFEXITED(status));
 //printf("waiting,success,exit_signal:%d exit_code:%d\n",WIFEXITED(status),WEXITSTATUS(status));
  return 0;
}
